filechooserbutton: Make dialog modal by default
authorMatthias Clasen <mclasen@redhat.com>
Mon, 13 Apr 2020 04:12:30 +0000 (00:12 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 13 Apr 2020 04:12:30 +0000 (00:12 -0400)
This is the expected behavior, so default to it.

gtk/gtkfilechooserbutton.c

index 090e829eb16f56ad4f8a960c42817980e0c004fa..8b4134135b9f6f6b1b7071979480daaebec9aa07 100644 (file)
@@ -534,7 +534,7 @@ gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class)
                                   g_param_spec_boolean ("modal",
                                                         P_("Modal"),
                                                         P_("Whether to make the dialog modal"),
-                                                        FALSE,
+                                                        TRUE,
                                                         GTK_PARAM_READWRITE));
 
   _gtk_file_chooser_install_properties (gobject_class);
@@ -871,12 +871,13 @@ gtk_file_chooser_button_constructed (GObject *object)
   if (!button->dialog)
     {
       button->native = gtk_file_chooser_native_new (NULL,
-                                                  NULL,
-                                                 GTK_FILE_CHOOSER_ACTION_OPEN,
-                                                 NULL,
-                                                 NULL);
+                                                    NULL,
+                                                    GTK_FILE_CHOOSER_ACTION_OPEN,
+                                                    NULL,
+                                                    NULL);
       button->chooser = GTK_FILE_CHOOSER (button->native);
       gtk_file_chooser_button_set_title (button, _(DEFAULT_TITLE));
+      gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (button->native), TRUE);
 
       g_signal_connect (button->native, "response",
                         G_CALLBACK (native_response_cb), object);
@@ -2404,15 +2405,11 @@ open_dialog (GtkFileChooserButton *button)
         {
           if (GTK_IS_WINDOW (toplevel))
             {
-              gboolean modal;
-
               if (GTK_WINDOW (toplevel) != gtk_window_get_transient_for (GTK_WINDOW (button->dialog)))
                 gtk_window_set_transient_for (GTK_WINDOW (button->dialog),
                                               GTK_WINDOW (toplevel));
-
-              g_object_get (button->dialog, "modal", &modal, NULL);
-              gtk_window_set_modal (GTK_WINDOW (button->dialog),
-                                    modal | gtk_window_get_modal (GTK_WINDOW (toplevel)));
+              if (gtk_window_get_modal (GTK_WINDOW (toplevel)))
+                gtk_window_set_modal (GTK_WINDOW (button->dialog), TRUE);
             }
         }
     }
@@ -2422,15 +2419,12 @@ open_dialog (GtkFileChooserButton *button)
         {
           if (GTK_IS_WINDOW (toplevel))
             {
-              gboolean modal;
-
               if (GTK_WINDOW (toplevel) != gtk_native_dialog_get_transient_for (GTK_NATIVE_DIALOG (button->native)))
                 gtk_native_dialog_set_transient_for (GTK_NATIVE_DIALOG (button->native),
                                                      GTK_WINDOW (toplevel));
 
-              g_object_get (button->native, "modal", &modal, NULL);
-              gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (button->native),
-                                           modal | gtk_window_get_modal (GTK_WINDOW (toplevel)));
+              if (gtk_window_get_modal (GTK_WINDOW (toplevel)))
+                gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (button->native), TRUE);
             }
         }
     }